package com.buanalintas.sandals.pos.priceonline;

import com.buanalintas.bynga.Dictionary;
import com.buanalintas.bynga.Field;
import com.buanalintas.bynga.Page;
import com.buanalintas.bynga.formatter.MoneyFormatter;
import com.buanalintas.sandals.pos.entities.PosMasterPriceOnline;

public class PriceOnline extends Page {

    private Field priceOnlineId;
    private Field priceOnlineValue;

    public PriceOnline() {
        setTheClass(PosMasterPriceOnline.class);

        priceOnlineId = new Field();
        priceOnlineId.setName("priceOnlineId");
        priceOnlineId.setCaption("id");
        priceOnlineId.setListProperties(" align=\"right\" width=\"5%\" nowrap");
        priceOnlineId.setInputProperties(" size=\"20\"");
        getFields().add(priceOnlineId);

        priceOnlineValue = new Field();
        priceOnlineValue.setName("priceOnlineValue");
        priceOnlineValue.setCaption("price online");
        priceOnlineValue.setListProperties(" align=\"right\" width=\"95%\" nowrap");
        priceOnlineValue.setInputProperties(" size=\"30\" ");
        priceOnlineValue.setFormater(MoneyFormatter.getInstance());
        priceOnlineValue.setRequired(true);
        getFields().add(priceOnlineValue);
        
        fillFields();

        getFieldsAdd().remove(priceOnlineId);
        getFieldsEdit().remove(priceOnlineId);
        getFieldsList().remove(priceOnlineId);
        
        setExportList(getClass().getResourceAsStream("PriceOnlineList.jasper"));
        setExport(getClass().getResourceAsStream("PriceOnline.jasper"));
        getController().setOrder(priceOnlineValue);
    }

    @Override
    public void beforeExport() {
        getExportParams().put("title", Dictionary.getValue(this, "Price Online"));
    }

    @Override
    public void beforeExportMulti() {
        beforeExport();
    }
}
